{
  "metadata" : {
    "config" : {
      "dependencies" : {
        
      },
      "exclusions" : [
      ],
      "repositories" : [
      ],
      "sparkConfig" : {

      }
    }
  },
  "nbformat" : 4,
  "nbformat_minor" : 0,
  "cells" : [
    {
      "cell_type" : "markdown",
      "execution_count" : 0,
      "metadata" : {
        "language" : "text"
      },
      "language" : "text",
      "source" : [
        "# Accessing a Scala object in Python\n",
        "\n",
        "\n",
        "You can call methods and properties of Scala objects in Python code. Consider the following Scala class:\n",
        "\n",
        "\n"
      ],
      "outputs" : [
      ]
    },
    {
      "cell_type" : "code",
      "execution_count" : 1,
      "metadata" : {
        "cell.metadata.exec_info" : {
          "startTs" : 1572054439197,
          "endTs" : 1572054441590
        },
        "language" : "scala"
      },
      "language" : "scala",
      "source" : [
        "class MySimpleClass(val i: Int = 12345) {\n",
        "    def f = \"hello world\"\n",
        "    def add(a: Float, b: Float) = a + b\n",
        "    def getLength[T](thing: java.util.ArrayList[T]) = thing.size()\n",
        "}\n",
        "val scInst = new MySimpleClass()"
      ],
      "outputs" : [
      ]
    },
    {
      "cell_type" : "code",
      "execution_count" : 2,
      "metadata" : {
        "cell.metadata.exec_info" : {
          "startTs" : 1572054441599,
          "endTs" : 1572054442693
        },
        "language" : "python"
      },
      "language" : "python",
      "source" : [
        "scInst.f()"
      ],
      "outputs" : [
        {
          "execution_count" : 2,
          "data" : {
            "text/plain" : [
              "hello world"
            ]
          },
          "metadata" : {
            "name" : "Out",
            "type" : "String"
          },
          "output_type" : "execute_result"
        }
      ]
    },
    {
      "cell_type" : "code",
      "execution_count" : 3,
      "metadata" : {
        "cell.metadata.exec_info" : {
          "startTs" : 1572054442695,
          "endTs" : 1572054442814
        },
        "language" : "python"
      },
      "language" : "python",
      "source" : [
        "scInst.i() # Note that the `()` are necesary"
      ],
      "outputs" : [
        {
          "execution_count" : 3,
          "data" : {
            "text/plain" : [
              "12345"
            ]
          },
          "metadata" : {
            "name" : "Out",
            "type" : "Long"
          },
          "output_type" : "execute_result"
        }
      ]
    },
    {
      "cell_type" : "code",
      "execution_count" : 4,
      "metadata" : {
        "cell.metadata.exec_info" : {
          "startTs" : 1572054442815,
          "endTs" : 1572054442940
        },
        "language" : "python"
      },
      "language" : "python",
      "source" : [
        "from math import pi\n",
        "scInst.add(1.0, pi)"
      ],
      "outputs" : [
        {
          "execution_count" : 4,
          "data" : {
            "text/plain" : [
              "4.141592979431152"
            ]
          },
          "metadata" : {
            "name" : "Out",
            "type" : "Double"
          },
          "output_type" : "execute_result"
        }
      ]
    },
    {
      "cell_type" : "code",
      "execution_count" : 5,
      "metadata" : {
        "cell.metadata.exec_info" : {
          "startTs" : 1572054442942,
          "endTs" : 1572054443073
        },
        "language" : "python"
      },
      "language" : "python",
      "source" : [
        "scInst.getLength([1, 2, 3, 4])"
      ],
      "outputs" : [
        {
          "execution_count" : 5,
          "data" : {
            "text/plain" : [
              "4"
            ]
          },
          "metadata" : {
            "name" : "Out",
            "type" : "Long"
          },
          "output_type" : "execute_result"
        }
      ]
    }
  ]
}